package com.floreysoft.jmte.staticCompiler.sample;

import com.floreysoft.jmte.Engine;
import com.floreysoft.jmte.TemplateContext;
import com.floreysoft.jmte.realLife.model.Order;
import com.floreysoft.jmte.template.AbstractCompiledTemplate;

public class EmailTemplate extends AbstractCompiledTemplate {
	private EmailStringProvider stringProvider;

	public EmailTemplate(Engine engine) {
		super(engine);
		stringProvider = new EmailStringProvider(engine);
		
	}

	
	@Override
	// shows what we can achieve when we know top level types at compile time
	protected String transformCompiled(TemplateContext context) {
		final Order order = (Order) context.model.get("order");
		final String separator = (String) context.model.get("separator");
		
		final String result = stringProvider.toString(order, separator);
		return result;
	}
}
